package com.learn.rabbitmq.eight.rejection;

import com.learn.rabbitmq.utils.RabbitMqUtils;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;

import java.nio.charset.StandardCharsets;

/**
 * 死信队列
 * <p>
 * 生产者
 */
public class Producer01Rejection {
    //普通交换机
    public static final String NORMAL_EXCHANGE = "normal_exchange";
    //普通队列
    public static final String NORMAL_QUEUE = "normal_queue";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtils.getChannel();


        /**
         *
         * 不影响消费者杀死队列
         *
         */
        channel.exchangeDeclare(NORMAL_EXCHANGE, BuiltinExchangeType.DIRECT);
        channel.queueBind(NORMAL_QUEUE, NORMAL_EXCHANGE, "zhangsan");

        //手动确认
        //channel.confirmSelect();

        for (int i = 1; i <= 10; i++) {
            String message = "info" + i;
            channel.basicPublish(NORMAL_EXCHANGE,
                    "zhangsan",
                    null,
                    message.getBytes(StandardCharsets.UTF_8));

        }


    }
}
